package com.aerilys.taskboard.client.activities;

import com.aerilys.taskboard.client.places.AddTaskViewPlace;
import com.aerilys.taskboard.client.places.DetailsViewPlace;
import com.aerilys.taskboard.client.places.GeneralViewPlace;
import com.aerilys.taskboard.client.tools.ClientFactory;
import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper
{
  private ClientFactory clientFactory;

  public AppActivityMapper(ClientFactory clientFactory) {
      super();
      this.clientFactory = clientFactory;
  }

  @Override
  public Activity getActivity(Place place) {
      if (place instanceof GeneralViewPlace)
          return new GeneralActivity((GeneralViewPlace) place, clientFactory);
      else if (place instanceof DetailsViewPlace)
          return new DetailsActivity((DetailsViewPlace) place, clientFactory);
      else if (place instanceof AddTaskViewPlace)
        return new AddTaskActivity((AddTaskViewPlace) place, clientFactory);
      return null;
  }

}
